<!--#include file="lib/utf-8.asp"-->
<!--#include file="lib/connopen.asp"-->
<!--#include file="lib/asp-common-lib.asp"-->
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CC的办公系统</title>
<!--#include file="lib/plugins.asp"-->
<style type="text/css">
  .ui-datepicker table {
    border: 0;
  }
</style>
<script type="text/javascript">
  $(function() {
  });
</script>
<!--#include file="lib/js-google-analytics.asp"-->
</head>
<%
if not CheckPostFlag(session("aaPostFlag"),0,15) then call JumpErrorPage(2)
submit=request.form("submit")
If submit<>"" Then
  conn.BeginTrans
  empe_id=request.form("empe_id")
  empe_name=request.form("empe_name")
  empe_dept=request.form("empe_dept")
  empe_room=request.form("empe_room")
  empe_short=request.form("empe_short")
  empe_mobile=request.form("empe_mobile")
  empe_index=request.form("empe_index")
  empe_leave=request.form("empe_leave")
  if empe_leave<>1 then empe_leave=0
  if submit="新增" then
    sql="insert into empe(empe_name,empe_dept,empe_index,empe_leave,empe_room,empe_short,empe_mobile) values('"&empe_name&"',"&empe_dept&","&empe_index&","&empe_leave&",'"&empe_room&"','"&empe_short&"','"&empe_mobile&"')"
    'response.write(sql)
    'response.end
    empe_id=ExecuteCommand(sql,true)
  end if
  if submit="保存" then
    sql="update empe set empe_name='"&empe_name&"',empe_room='"&empe_room&"',empe_short='"&empe_short&"',empe_mobile='"&empe_mobile&"',empe_dept="&empe_dept&",empe_index="&empe_index&",empe_leave="&empe_leave&" where empe_id="&empe_id
    call ExecuteCommand(sql,false)
  end if
  if err.number=0 then 
    conn.CommitTrans  '如果没有conn错误，则执行事务提交
  else
    conn.RollbackTrans '否则回滚
    '回滚后的其他操作
    'strerr=err.Description
    url=request.ServerVariables("http_host")&request.ServerVariables("url")
    Response.Write "数据库错误！<br /><font color=red>Error # " & CStr(Err.Number) & "<br />" & Err.Description & "<br />Source: " & Err.Source &"<br />错误页面："&url&"</font><br />"
    Response.End
  end if
else
  empe_id=request.querystring("empe_id")
  dept_id=request.querystring("dept_id")
end if

if empe_id<>"" then
  Set rs = Server.CreateObject("ADODB.Recordset")
  sql="select * from empe where empe_id="&empe_id
  rs.Open sql,conn,1,1
  if not rs.eof then
    empe_name=rs("empe_name")
    empe_dept=rs("empe_dept")
    empe_room=rs("empe_room")
    empe_short=rs("empe_short")
    empe_mobile=rs("empe_mobile")
    empe_index=rs("empe_index")
    empe_leave=rs("empe_leave")
  else
    response.write("没有此员工")
    response.end
  end if
  rs.close
  set rs=nothing
end if
%>
<body>
<!--#include file="lib/header.asp"-->
<!--#include file="lib/nav.asp"-->
<div id="main">
<!--#include file="lib/col1.asp"-->
<!--#include file="lib/col2.asp"-->
  <div id="col3" role="main">
    <div id="col3_content" class="clearfix">
      <form name="form1" method="post" class="yform" role="application">
      员工：	<input name="empe_name" value="<%=empe_name%>" />
      部门：			<select id="empe_dept" name="empe_dept">
                  <%
                    Set rs_dept = Server.CreateObject("ADODB.Recordset")
                    sql_dept = "SELECT * FROM dept order by dept_name"
                    rs_dept.Open sql_dept,conn,1,1
                    do while not rs_dept.eof
                  %>
                    <option value="<%=rs_dept("dept_id")%>" <%if empe_dept=rs_dept("dept_id") then response.write("selected='selected'")%>><%=rs_dept("dept_name")%></option>
                  <%
                      rs_dept.movenext
                    loop
                    rs_dept.close
                    set rs_dept=nothing
                  %>
                  </select>
                  
      办公室：	<input name="empe_room" size="10" value="<%=empe_room%>" />
      短号：	<input name="empe_short" size="4" value="<%=empe_short%>" />
      手机：	<input name="empe_mobile" size="11" maxlength="11" value="<%=empe_mobile%>" />
      排序：	<input name="empe_index" size="2" maxlength="2" value="<%=empe_index%>" />
      离职：	<input name="empe_leave" type="checkbox" <%if empe_leave then response.write("checked='checked'")%> value="1" />
          <input type="hidden" name="empe_id" value="<%=empe_id%>" />
          <input type="submit" name="submit" value="保存" />
          <input type="submit" name="submit" value="新增" />
          <input name="reset" type="reset" value="重置" />
      </form>		
      <table class="full">
        <thead>
          <tr>
            <th>序号</th>
            <th>员工</th>
            <th>部门</th>
            <th>电话</th>
            <th>办公室</th>
            <th>短号</th>
            <th>手机</th>
            <th>排序</th>
            <th>离职</th>
            <th>删除</th>
          </tr>
        </thead>
        <tbody>
      <%
        Set rs = Server.CreateObject("ADODB.Recordset")
        sql = "select * from empe_dept order by dept_index asc,empe_index asc"
        if dept_id<>"" then sql="select * from empe_dept where dept_id="&dept_id&" order by dept_index asc,empe_index asc"
        rs.Open sql,conn,1,1
        do while not rs.eof
      %>
          <tr>
            <td><%=rs.AbsolutePosition%></td>
            <td><a href="empe.asp?empe_id=<%=rs("empe_id")%>"><%=rs("empe_name")%></a></td>
            <td><a href="empe.asp?dept_id=<%=rs("dept_id")%>"><%=rs("dept_name")%></a></td>
            <td></td>
            <td><%=rs("empe_room")%></td>
            <td><%=rs("empe_short")%></td>
            <td><%=rs("empe_mobile")%></td>
            <td><%=rs("empe_index")%></td>
            <td><%if rs("empe_leave") then response.write("离职")%></td>
            <td><a href="del_empe.asp?empe_id=<%=rs("empe_id")%>">删除</a></td>
          </tr>
      <%
          rs.movenext
        loop
        rs.close
        set rs=nothing
      %>
        </tbody>
      </table>
    </div>
  </div>
</div>
<!--#include file="lib/footer.asp"-->
</body>
</html>
<!--#include file="lib/connclose.asp"-->

